package br.com.screen;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

import br.com.core.Usuario;

public class ScreenConta extends JFrame implements ActionListener {

	JTextField nome;
	JTextField matricula;
	JPasswordField senha;
	JButton cadastrar;
	JComboBox curso;
	JRadioButton aluno;
	JRadioButton professor;
	JRadioButton tecnico;
	
	public ScreenConta() {
		super("Conta");
		
		Container container = new JPanel();
		JLabel nome_ = new JLabel("Nome");
		JLabel matricula_ = new JLabel("Matrícula");
		JLabel senha_ = new JLabel("Senha");
		JLabel categoria_ = new JLabel("Categoria");
		JLabel curso_ = new JLabel("Curso");
		nome = new JTextField();
		matricula = new JTextField();
		senha = new JPasswordField();
		curso = new JComboBox();
		curso.addItem("Ciência da Computação");
		curso.addItem("Administração");
		curso.addItem("Agronomia");
		cadastrar = new JButton("Cadastrar");
		ButtonGroup categoria = new ButtonGroup(); 
		aluno = new JRadioButton("Aluno");
		professor = new JRadioButton("Professor");
		tecnico = new JRadioButton("Técnico");
		categoria.add(aluno);
		categoria.add(professor);
		categoria.add(tecnico);
		
		
		javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(container);
        container.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(34, 34, 34)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tecnico)
                            .addComponent(professor)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                    .addComponent(aluno)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                                    .addComponent(curso, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(categoria_)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(curso_))
                                .addComponent(senha_, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(matricula_, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(nome_, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(nome, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(matricula, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(senha, javax.swing.GroupLayout.Alignment.LEADING))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(137, 137, 137)
                        .addComponent(cadastrar)))
                .addContainerGap(34, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addComponent(nome_)
                .addGap(7, 7, 7)
                .addComponent(nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(matricula_)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(matricula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(senha_)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(senha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(categoria_)
                    .addComponent(curso_))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(aluno)
                    .addComponent(curso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(professor)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tecnico)
                .addGap(18, 18, 18)
                .addComponent(cadastrar)
                .addContainerGap(26, Short.MAX_VALUE))
        );
        
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
		
		
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setSize(300, 420);
		setVisible(true);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		cadastrar.addActionListener( 

				new ActionListener() { 

					public void actionPerformed(ActionEvent event) { 
						Usuario usuario = new Usuario();
						usuario.setNome(nome.getText());
						usuario.setMatricula(matricula.getText());
						usuario.setSenha(senha.getText()); // Isto deve ser feito de outra forma
						usuario.setCurso(curso.getActionCommand());
						System.out.println(usuario.getNome());
					} 
		
				});
	}
}
